<?php
/**
 * Array of templates.
 *
 * Contains:
 *   Header
 * 
 *   IndexOpen
 *   IndexElem
 *   IndexClose
 * 
 *   MessageForm
 *   MessageBody
 *   CommentForm
 *   CommentBody
 * 
 *   Footer
 * 
 * Global variables:
 *   title, page
 * 
 * @author Kirill Krasnoschekov
 */
 
$tmpl = array(
/* 
 * Header 
 */
'Header' => 
'<html>
    <head>
        <link rel="stylesheet" type="text/css" href="stylesheet.css" />
        <script language="javascript">
            function ToggleHidden(id)
            {
                var div = document.getElementById(id);
                if (div.style.display == "block")
                { 
                    div.style.display = "none";
                }
                else
                {
                    div.style.display = "block";
                    div.focus();
                }
            }
        </script>
    </head>
    
    <body>
        <!-- Header -->
        <div class="header">
            <h1>{title}</h1>
        </div>',
/* 
 * IndexOpen 
 */        
'IndexOpen' => '<div> Pages: ',
/*
 * IndexElem
 * curpage0 is current page indexed from 0 to N-1
 * curpage1 is current page indexed from 1 to N
 */        
'IndexElem' =>
'<a href="index.php?page={curpage0}"> {curpage1} </a>',
/*
 * IndexClose
 */
'IndexClose' => '</div>',
/*
 * MessageForm
 */
'MessageForm' =>
'        <!-- Message form -->
        <form class="message" method="post" action="index.php">
            <input type="hidden" name="page" value="{page}">
            <input type="hidden" name="mode" value="add">
            <p>
                <div>Name:</div> 
                <input type="text" name="name" value="{name}" size="24" maxlength="24"/>
            </p>
            <p>
                <div>Text:</div> 
                <textarea name="text" rows="8" cols="40">{text}</textarea>
            </p>
            <input type="submit" value="Post a message"/>
        </form>
        <!-- /Message form -->',
/*
 * MessageBody
 */        
'MessageBody' => 
'        <!-- Message body -->
        <div class="message">
            <!-- Message actions -->
            <div>
                <a href="index.php?page={page}&mode=delete&msgid={id}">Delete</a>
                <a href="javascript:ToggleHidden(\'MsgEditForm{id}\')">Edit</a>
            </div>
            
            <!-- Edit form (hidden by default) -->
            <form method="post" action="index.php" id="MsgEditForm{id}">
                <!-- No need for this:
                    message rises to the top after updating.
                <input type="hidden" name="page" value="{page}">
                -->
                <input type="hidden" name="mode" value="update">
                <input type="hidden" name="msgid" value="{id}">
                <p>
                    <div>Name:</div> 
                    <input type="text" name="name" value="{name}" size="24" maxlength="24"/>
                </p>
                <p>
                    <div>Text:</div> 
                    <textarea name="text" rows="8" cols="40">{text}</textarea>
                </p>
                <input type="submit" value="Save changes"/>
            </form>
            
            <!-- Message contents -->
            <div class="timestamp">{timestamp}</div>
            <div class="name">{name}</div>
            <div class="text">{textbr}</div>
            <div>
                <a href="javascript:ToggleHidden(\'CommentForm{id}\');">Write a comment</a>
            </div>
        </div>
        <!-- /Message body -->',
/*
 * CommentForm
 */
'CommentForm' => 
'        <!-- Comment form -->
        <form class="comment" method="post" action="index.php"  id="CommentForm{msgid}">
            <input type="hidden" name="page" value="{page}">
            <input type="hidden" name="mode" value="add">
            <input type="hidden" name="msgid" value="{msgid}">
            <p>
                <div>Name:</div> <input type="text" name="name" value="{name}" size="24" maxlength="24"/>
            </p>
            <p>
                <div>Text:</div> <textarea name="text" rows="8" cols="40">{text}</textarea>
            </p>
            <input type="submit" value="Post a comment"/>
        </form>
        <!-- /Comment form -->',
/*
 * CommentBody
 */
'CommentBody' => 
'        <!-- Comment body -->
        <div class="comment">
            <!-- Comments actions -->
            <div>
                <a href="index.php?page={page}&mode=delete&commentid={id}">Delete</a>
            </div>
 
            <div class="timestamp">{timestamp}</div>
            <div class="name">{name}</div>
            <div class="text">{textbr}</div>
        </div>
        <!-- /Comment body -->',
/*
 * Footer
 */
'Footer' =>
'    <!-- Footer -->
    <div class="time">Elapsed time: {time}</div>
    </body>
</html>'
);

?>